use core::source::{Source, SourceMap};
use sources::PathSource;
use util::{CargoResult, human, ChainError, Config};
-use ops::{self, Layout, Context, BuildConfig};
+use ops::{self, Layout, Context, BuildConfig, Kind};
pub struct CleanOptions<'a, 'b: 'a> {
pub spec: Option<&'a str>,
try!(rm_rf(&layout.fingerprint(&pkg)));
let profiles = [Profile::default_dev(), Profile::default_test()];
for profile in profiles.iter() {
- for filename in try!(cx.target_filenames(&pkg, target, profile)).iter() {
+ for filename in try!(cx.target_filenames(&pkg, target, profile,
+ Kind::Target)).iter() {
try!(rm_rf(&layout.dest().join(&filename)));
try!(rm_rf(&layout.deps().join(&filename)));
}
/// Return the filenames that the given target for the given profile will
/// generate.
pub fn target_filenames(&self, pkg: &Package, target: &Target,
- profile: &Profile) -> CargoResult<Vec<String>> {
+ profile: &Profile, kind: Kind)
+ -> CargoResult<Vec<String>> {
let stem = self.file_stem(pkg, target, profile);
let suffix = if target.for_host() {&self.host_exe} else {&self.target_exe};
for lib in libs.iter() {
match *lib {
LibKind::Dylib => {
- let plugin = target.for_host();
- let kind = if plugin {Kind::Host} else {Kind::Target};
let (prefix, suffix) = try!(self.dylib(kind));
ret.push(format!("{}{}{}", prefix, stem, suffix));
}
info!("fingerprint at: {}", loc.display());
- let fingerprint = try!(calculate(cx, pkg, target, profile, kind));
- let is_fresh = try!(is_fresh(&loc, &fingerprint));
+ let mut fingerprint = try!(calculate(cx, pkg, target, profile, kind));
+ let is_fresh = try!(is_fresh(&loc, &mut fingerprint));
let root = cx.out_dir(pkg, kind, target);
let mut missing_outputs = false;
if !profile.doc {
- for filename in try!(cx.target_filenames(pkg, target, profile)).iter() {
+ for filename in try!(cx.target_filenames(pkg, target, profile,
+ kind)).iter() {
missing_outputs |= fs::metadata(root.join(filename)).is_err();
}
}
cx.compilation.extra_env.insert("OUT_DIR".to_string(), out_dir);
for &(target, profile) in targets {
- for filename in try!(cx.target_filenames(pkg, target, profile)).iter() {
- let dst = cx.out_dir(pkg, Kind::Target, target).join(filename);
+ let kind = Kind::Target;
+ for filename in try!(cx.target_filenames(pkg, target, profile,
+ kind)).iter() {
+ let dst = cx.out_dir(pkg, kind, target).join(filename);
if profile.test {
cx.compilation.tests.push((target.name().to_string(), dst));
} else if target.is_bin() || target.is_example() {
if profile.doc { continue }
if cx.compilation.libraries.contains_key(&pkgid) { continue }
- let v = try!(cx.target_filenames(pkg, target, profile));
+ let v = try!(cx.target_filenames(pkg, target, profile, kind));
let v = v.into_iter().map(|f| {
- (target.clone(),
- cx.out_dir(pkg, Kind::Target, target).join(f))
+ (target.clone(), cx.out_dir(pkg, kind, target).join(f))
}).collect::<Vec<_>>();
cx.compilation.libraries.insert(pkgid.clone(), v);
}
}
let exec_engine = cx.exec_engine.clone();
- let filenames = try!(cx.target_filenames(package, target, profile));
+ let filenames = try!(cx.target_filenames(package, target, profile,
+ kind));
let root = cx.out_dir(package, kind, target);
// Prepare the native lib state (extra -L and -l flags)
// If this target is itself a plugin *or* if it's being linked to a
// plugin, then we want the plugin directory. Otherwise we want the
// target directory (hence the || here).
- let layout = cx.layout(pkg, match kind {
+ let kind = match kind {
Kind::Host => Kind::Host,
Kind::Target if target.for_host() => Kind::Host,
Kind::Target => Kind::Target,
- });
+ };
+ let layout = cx.layout(pkg, kind);
- for filename in try!(cx.target_filenames(pkg, target, profile)).iter() {
+ for filename in try!(cx.target_filenames(pkg, target, profile, kind)).iter() {
if filename.ends_with(".a") { continue }
let mut v = OsString::new();
v.push(&target.crate_name());